package com.leo.contentcenter.controller.content;

import com.leo.contentcenter.domain.dto.content.ShareDTO;
import com.leo.contentcenter.service.content.ShareService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 让这个controller有独立的线程池
 * thread-pool-1 10
 * @author leo
 */
@RestController
@RequestMapping("/shares")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ShareController {

    private final ShareService shareService;

    /**
     * 调用远程接口获取用户信息
     * 如果5秒以内的错误率、错误次数
     * 达到阈值就跳闸
     * @param id id
     * @return 用户信息
     */
    @GetMapping("/{id}")
    public ShareDTO findById(@PathVariable Integer id) {
        return this.shareService.findById(id);
    }
}
